Rate control for coding audio frames

ABSTRACT

To determine the number of bits to encode a current audio frame, in accordance with a running average of the common scale factors for all preceding audio frames, a common scale factor for the-current frame is computed. The current frame is encoded using the computed common scale factor if the same falls within a defined range, and the number of bits required to so encode the frame also falls within a calculated range. If, the number of bits required to so encode the frame falls outside the calculated range, an energy level associated with the current frame and a running average of the energies of all previous frames is computed, which in turn, are used to compute a target bit rate. Thereafter, a common scale factor which results in coding of the current frame using a number of bits close to the target bit rate is obtained.

CROSS-REFERENCES TO RELATED APPLICATIONS

[0001] NOT APPLICABLE

STATEMENT AS TO RIGHTS TO INVENTIONS MADE UNDER FEDERALLY SPONSORED RESEARCH OR DEVELOPMENT

[0002] NOT APPLICABLE

REFERENCE TO A “SEQUENCE LISTING,” A TABLE, OR A COMPUTER PROGRAM LISTING APPENDIX SUBMITTED ON A COMPACT DISK.

[0003] NOT APPLICABLE

BACKGROUND OF THE INVENTION

[0004] The present invention relates to audio frames, and more particularly to the control of bit rates for encoding of such frames.

[0005] Constant bit-rate and variable length encoding are both used to encode and store audio signals. In accordance with constant bit-rate encoding, a constant bit-rate is used to encode (i.e., compress) and/or store the audio signals. For example, many of the audio tracks stored on Compact Discs (CDs) are sampled at constant rates of 44.1 KHz or 48 KHz. If an audio track is stored at the constant rate of 44.1 KHz, 44100 samples per second are required in order to play back that track of the CD. For each audio channel, each sample point is typically represented by a 16-bit data. Therefore, when playing the track using, e.g., two channels, a throughput of 1.411 Mbits/sec (i.e., 44100*16*2=1.411 Mbits/sec) is required. This bit rate is constant and does not vary with time.

[0006] In accordance with variable length coding, a variable bit-rate is used to compress audio signals. Therefore, various parts of the signals are sampled at different rates and thus the compressed bit streams have variable bit rates at different times. For most transmission channels or media, the bit stream has a constant rate during any short period of time. Therefore, the decoding buffer that stores unused bits, does not typically suffer from underflow or overflow problem.

[0007]FIG. 1 illustrates the concept related to changing a variable bit rate to constant bit rate using a leaky bucket analogy. Assume that the bucket has a fixed size and has a hole at its bottom. The hole empties the water kept in the bucket at a constant rate, while the water may enter the bucket at different rates. The bucket (e.g., the decoding buffer) is so adapted as to ensure that the variable rate at which water enters the bucket does not cause the bucket to overflow (e.g., the decoding buffer is full and cannot store any more bits) or become empty (e.g., the decoding buffer does not have any unused bits).

[0008] In order to have high fidelity quality when playing back compressed audio, the compressed audio is required not to have a large amount of distortion. The smaller the distortion, the higher the fidelity and the higher is the bit rate required for compression. To meet both requirements of constant bit rate and high fidelity, a rate control algorithm is required for an audio codec (i.e., coder/decoder). Such a rate control algorithm regulates the bit rate so as to satisfy the virtual buffer requirement while keeping the compression distortion as small as possible.

[0009] In the Advanced Audio Coding (AAC) codec of the MPEG4 standard, each 2048 time-domain audio samples are transformed to 1024 frequency-domain data using a Modified Discrete Cosine Transform (MDCT). Assume C_(i), is the i-th MDCT coefficient of such a transformation, where i=0, . . . , 1023. These coefficients are grouped into N scale factor bands with size L_(k), where k=0, . . . , N-1, where N may have a value from 16 to 49, and where ${\sum\limits_{k = 0}^{N - 1}L_{k}} = 1024.$

[0010] The MDCT coefficients of k-th scale factor band are quantized using a non-uniform quantizer using a quantization step size s_(k)=(Q−q_(k)), as shown below: $\begin{matrix} {x_{i} = {{int}\left( {\left( {{C_{i}} \times 2^{\frac{1}{4} \times {({q_{k} - Q})}}} \right)^{\frac{3}{4}} + m} \right)}} & (1) \end{matrix}$

[0011] In equation (1) above, x_(i) represents the i-th time-domain audio input sample, m is a constant equal to 0.4054, Q is the common scale factor, and q_(k) is the k-th scale factor, which adjusts the common scale factor for k-th scale factor band, and int( ) is an operator that extracts the integer part of the numerical value inside the parenthesis. The scalar factors and common scale factor are transmitted in the bit stream and are used to reverse the quantization process during decoding. The quantized MDCT coefficients are coded using VLC and the results are used to form a compressed bit stream.

[0012] The larger the step size in quantization, the larger the distortion and the smaller the bit rate are. An effective rate control maintains the smallest possible quantization step size while keeping the output bit stream constant. The output bit rate may be varied by varying the values of a number of control parameters. If, for example, the output bit rate fails to satisfy the virtual buffer limitations, the frame needs to be encoded using different parameter values. Typically several iterations are required before an acceptable output bit rate is achieved. Because the output bit rate is not known until the frame is encoded, bit rate control is a time-consuming and challenging task

[0013] A widely known technique for bit rate control, commonly known as a two-loop technique, and described in the publication: “ISO/IEC 14496-3, Information Technology—Generic Coding of Audiovisual Objects, Part 3: Audio, Subpart 4: General Audio Coding: AAC/TwinVQ”, quantizes the MDCT coefficients in an iterative process in accordance with several requirements. An inner loop quantizes the coefficients and increases the quantization step size until the output can be coded with the available number of bits. Thereafter—following completion of the inner loop—an outer loop checks the distortion associated with each scale factor band. If the distortion of a scale factor band exceeds a predefined limit, the band is amplified by increasing its scale factor and the inner loop operation is reengaged.

[0014] As described above, the two-loop technique is adapted to find the common scale factor Q and scale factors q_(k) for each scale band, k=0, . . . , N-1, concurrently. Since this involves solving multi-dimensional optimization problem with many unknowns, it poses a challenging task. The problem is further compounded by the requirement that for each set of unknowns, the audio frame is encoded once to find the number of encoding bits, which may require a large number of computations. Moreover, there are situations when the inner and outer loops may require a large number of iterations, e.g., 25, to converge. In other situations the inner and outer loops may not converge, which may require the loops to be terminated after a few iterations. Such terminations may lead to a set of scale factors and common scale factor values that result in large distortions. Moreover, the virtual buffer may suffer from overflow or underflow.

[0015] A need continues to exist for rate control algorithm that requires a relatively few iteration to find a set of quantization step sizes, and ensures that buffer overflows or underflows do not occur.

BRIEF SUMMARY OF THE INVENTION

[0016] In accordance with one aspect of the present invention, to determine the number of bits with which a current audio frame is encoded, first a minimum bit rate and a maximum bit rate for encoding of the current frame is established. Both the minimum bit rate and maximum bit rate are defined by (i) the number of bits currently stored in a buffer, (ii) the maximum number of bits that the buffer is adapted to store and (iii) an average bit rate. Next, in accordance with a running average of the common scale factors for all audio frames preceding the current audio frame, a common scale factor for the current frame is computed. If the computed common scale factor falls within a defined range, it is used to encode the frame. If the number of bits required to so encode the frame falls within the established minimum and maximum bit rates, the encoding is complete and the next frame is received.

[0017] If, on the other hand, the number of bits required to so encode the frame falls outside the established minimum and maximum bit rates, an energy level associated with the frame is computed. Also, a running average of the energies of all previous frames is computed. The energy level and the running average of the energies are used to compute a target bit rate. Thereafter, using any one of a number of optimization techniques, such a bisection algorithm, a common scale factor which results in coding of the current frame using a number of bits close to the target bit rate is obtained, e.g., a number of bits which is within 5% of the target bit rate.

[0018] In some embodiments of the present invention, the minimum and maximum number of bit rates B_(min) and B_(max) are defined in accordance with the following: $\begin{matrix} {B_{\min} = \left\{ \begin{matrix} 0 & {{{if}\quad U_{n}} > B_{avg}} \\ {B_{avg} - U_{n}} & {{{if}\quad U_{n}} \leq B_{avg}} \end{matrix} \right.} \\ {B_{\max} = {U_{\max} - U_{n} + B_{avg}}} \end{matrix}$

[0019] In these embodiments, the common scale factor Q_(n) for the current frame may computed using the running average of common scale factors θ_(n) of audio frames preceding the current audio frame in accordance with the following: ${Q_{n} = {\theta_{n} + {{round}\left( {\sigma_{1}\left( {\psi_{n} - \frac{\sigma_{2}}{8}} \right)} \right)}}};$

[0020] wherein θ_(n) is defined by:

θ_(n)=(1−α)Q_(n-1)+αθ_(n-1)

[0021] wherein σ₁ and σ₂ are programmable parameters, wherein ψ_(n) represent the buffer fullness defined by ${\psi_{n} = \frac{U_{n}}{U_{\max}}},$

[0022] wherein round( ) is an operator rounding the value of its operand, wherein θ_(n) is defined by θ_(n)=(1−α)Q_(n-1)+αθ_(n-1), wherein Q_(n-1) is a common scale factor for an audio frame preceding the current frame and wherein θ_(n-1) is a running average of common scale factors of audio frames preceding the frame preceding the current audio frame.

[0023] In some embodiments of the present invention, the minimum and maximum common scale factors Q_(min) and Q_(max) which define the range against which the computed common scale factor is compared are defined as following: $\begin{matrix} {Q_{\min} = \left\lbrack {\frac{- 16}{3}\quad \log_{2}\quad \frac{2^{13} - m}{M}} \right\rbrack} \\ {Q_{\max} = \left\lbrack {\frac{- 16}{3}\quad \log_{2}\frac{1 - m}{M}} \right\rbrack} \end{matrix}$

[0024] wherein m is a constant and wherein M is defined as ${M = {\underset{i}{Max}\left( {C_{i}}^{3/4} \right)}},{i = 0},\ldots \quad,1023$

[0025] wherein C_(i) is the i-th MDCT coefficient associated with the current audio frame.

[0026] In some embodiments, the energy level e_(n) associated with the frame and the running average of energies E_(n) of the audio frames preceding the current audio frame are defined by: $\begin{matrix} {e_{n} = {\frac{1}{N}{\sum\limits_{i = 0}^{N - 1}{c_{i}}}}} & \quad & \quad & {E_{n} = {\left( {1 - \beta} \right)\quad {\sum\limits_{i = {- \infty}}^{0}\beta^{- i}}}} \end{matrix}e_{i + n - 1}$

[0027] In these embodiments, the target bit rate B_(1n) is further defined by: $B_{1n} = {{\left( \frac{e_{n}}{E_{n}} \right)^{\sigma_{0}}B_{avg}} - {\frac{1}{8}{{round}\left( {\sigma_{1}\left( {\psi_{n} - \frac{\sigma_{2}}{8}} \right)} \right)}B_{avg}}}$

[0028] where σ₀ is a programmable parameter.

[0029] In accordance with another aspect of the present invention, a rate control technique is adapted to optimize the common scale factor Q for each frame using scale factors q_(k) that have selected values and thus do not require optimization. Accordingly, because the common scale factor Q for each frame becomes the only unknown, the rate control of the present inventions reduces the amount of computation required for obtaining the quantized MDCT coefficients. Moreover, the tradeoff between quantization distortion and output bit rate is achieved by varying the common scale factor Q.

[0030] In some embodiments, all scale factors q_(k) are selected to have the same constant value. In other embodiments, because humans are most sensitive to lower frequency signals, the scale factors associated with lower frequency bands are selected to have smaller values than those associated with lower frequency bands. In yet other embodiments, a look-up table may be used to select scale factors q_(k) values based on the frequency characteristic of the audio frame being encoded. Furthermore, in accordance with human acoustic responses, the scale factors may be selected such that larger step sizes are used for the scale factor bands that can tolerate larger quantization distortion.

[0031] In accordance with yet another aspect of the present invention, the same common scalar factor Q is used for each channel of multi-channel system. Moreover, the scalar factors selected for one channel of a multi-channel system, as described above, together with one or more offset values are used to define the scalar factors of the remaining channels of such a system. In other words, after the scalar factors for one channel of a multi-channel system is selected, they are modified by corresponding offset values to determine the scalar factors for the remaining channels. In some embodiments, all the offsets for all channels may be select to be equal to a constant. In other embodiments, the offsets are selected in accordance with the complexity of the channel, such as the energy associated with the frames forwarded to that channel.

BRIEF DESCRIPTION OF THE DRAWINGS

[0032]FIG. 1 illustrates a leaky bucket adapted to absorb variations in the incoming flow rate to generate a constant outgoing flow.

[0033]FIG. 2 is a graph of number of bits used in encoding of an audio frame as a function of common scale factor, in accordance with one embodiment of the present invention.

[0034]FIG. 3 is a flow-chart of steps carried out in determining bit rates for encoding audio frames, in accordance with one embodiment of the present invention.

DETAILED DESCRIPTION OF THE INVENTION

[0035] In accordance with a first aspect of the present invention, a rate control technique predicts the common scale factor Q for a current frame using previous common scale factors. If the common scale factor Q so predicted leads to buffer underflow or overflow, an optimization algorithm is used so that the number of bits remains close to a target value and within a defined limit. In some embodiments, the rate control technique predicts the common scale factor Q in accordance with the buffer fullness and a running average of previous common scale factors, as described further below.

[0036] Assume that U_(n) is the number of bits in the virtual buffer when encoding the n-th frame. Assume ψ_(n) represents the buffer fullness, i.e., the percentage of the buffer that is filled. For example, a value of 0.25 means that 25% of the buffer is filled. Note that 0≦ψ_(n)≦1, and $\begin{matrix} {\psi_{n} = \frac{U_{n}}{U_{\max}}} & (2) \end{matrix}$

[0037] where U_(max) is the size of buffer.

[0038] Assume further that B_(avg) is the target bit rate. Therefore, to inhibit virtual buffer underflow and overflow, the bit rate is required to fall in a range defined by B_(min), and B_(max), where: $\begin{matrix} {B_{\min} = \left\{ \begin{matrix} 0 & {if} & {U_{n} > B_{avg}} \\ {B_{avg} - U_{n}} & {if} & {U_{n} \leq B_{avg}} \end{matrix} \right.} & (3) \\ {B_{\max} = {U_{\max} - U_{n} + B_{avg}}} & (4) \end{matrix}$

[0039] To predict common scale factor Q_(n), a running average θ_(n) of all previous common scale factors is calculated, as shown below: $\begin{matrix} {\theta_{n} = {\left( {1 - \alpha} \right){\sum\limits_{i = {- \infty}}^{0}\quad {\alpha^{- i}Q_{i + n - 1}}}}} & (5) \end{matrix}$

[0040] where α is a user-defined programmable parameter, which controls the weighting of previous common scale factors. In some embodiments, α is defined to have a value of, e.g., 0.9 or {fraction (15/16)}. Equation (5) may be simplified as:

θ_(n)=(1−α)Q_(n-1)+αθ_(n-1)  (6)

[0041] Accordingly, Q_(n) may be predicted using the following equation: $\begin{matrix} {Q_{n} = {\theta_{n} + {{round}\left( {\sigma_{1}\left( {\psi_{n} - \frac{\sigma_{2}}{8}} \right)} \right)}}} & (7) \end{matrix}$

[0042] where the function round returns the nearest integer of its argument. As seen from equation (7), Q_(n) may be varied by the difference between the buffer fullness and a reference value. Both parameters σ₁ and σ₂ are programmable. In some embodiments, σ₁ is selected to be an integer ranging from 0 to 15, i.e., σ₁ ε {0, 1, . . . , 15} and σ₂ is selected to be an integer ranging from 0 to 8, i.e., σ₂ ε {0, 1, . . . , 8}. A value of 4 for σ₂ defines a condition where the buffer is half full.

[0043] Common scale factor Q_(n) is further required to remain within boundary limits Q_(min) and Q_(max). Therefore, if Q_(n) as computed above, falls below Q_(min) it is set to Q_(min). Similarly, if Q_(n) as computed above exceeds Q_(max), it is set Q_(max), as shown below: $\begin{matrix} {Q_{n} = \left\{ \begin{matrix} Q_{\min} & {if} & {Q_{1n} < Q_{\min}} \\ Q_{\max} & {if} & {Q_{1n} > Q_{\max}} \end{matrix} \right.} & (8) \end{matrix}$

[0044] In some embodiments, Q_(min) and Q_(max), which together define the limits of Q_(n), are computed as follows. Assume M represents the maximum value of the absolute values of MDCT coefficients raised to the three-fourth power of a current frame: $\begin{matrix} {{M = {\underset{i}{Max}\left( {C_{i}}^{3/4} \right)}},{i = 0},\ldots \quad,1023} & (9) \end{matrix}$

[0045] where C_(i) is the i-th MDCT coefficient. Assume that all the quantized MDCT coefficient are required to be in the range of [0, 2^(13].) Therefore, as seen from equation (1), the minimum and maximum possible common scale factors Q_(min) and Q_(max) are defined as below: $\begin{matrix} {Q_{\min} = \left\lbrack {\frac{- 16}{3}\log_{2}\frac{2^{13} - m}{M}} \right\rbrack} & (10) \\ {Q_{\max} = \left\lbrack {\frac{- 16}{3}\log_{2}\frac{1 - m}{M}} \right\rbrack} & (11) \end{matrix}$

[0046] Equations (10) and (11) may further be simplified if m is selected to be, e.g., 0.4054, as shown below: $\begin{matrix} {Q_{\min} = \left\lbrack {\frac{- 16}{3}\log_{2}\frac{2^{13}}{M}} \right\rbrack} & (12) \\ {Q_{\max} = \left\lbrack {\frac{- 16}{3}\log_{2}\frac{0.5}{M}} \right\rbrack} & (13) \end{matrix}$

[0047] As described above, in accordance with the present invention, common scale factor Q_(n) derived from equation (8) is used to encode the current frame. If the resulting bit rate B_(n) is within the range defined by B_(min), and B_(max), the encoding is declared as being successful, and the next frame becomes subject to encoding. If, on the other hand, the resulting bits rate B_(n) falls outside the range defined by B_(min), and B_(max), the common scale factor Q_(n), is varied so as to result in a bit rate B_(n), that falls within this range. If, the resulting bits rate B_(n) is less than B_(min.), the virtual buffer is filled by the number of dummy bits defined by the difference between these two rates, e.g., B_(min)-B_(n), and the frame is encoded using a filing encoding mode, as known in the prior art. The dummy bits are ignored by the decoder.

[0048] To vary the common scale factor Q_(n) so as to encode the frame with a bit rate B_(n) that falls within the range defined by B_(min), and B_(max), in accordance with a second aspect of present invention, an energy level associated with the current frame is first computed. The energy level, in accordance with the present invention, is a measure of the complexity of the current frame relative to all other previous frames. Because each frame is adapted to be encoded using a number bits related to its relative energy level, audio distortions are kept relatively small. Assume en represent the energy in L₁ norm and associated with the frame prior to encoding: $\begin{matrix} {e_{n} = {\frac{1}{N}{\sum\limits_{i = 0}^{N - 1}\quad {c_{i}}}}} & (14) \end{matrix}$

[0049] Assume further that E_(n) represents the running average of the energies associated with all the frames except the current frame: $E_{n} = {\left( {1 - \beta} \right){\sum\limits_{i = {- \infty}}^{0}\quad {\beta^{- i}e_{i + n - 1}}}}$

[0050] Energy E_(n) may thus be estimated using the following equation:

=(1−β)e_(n-1)+βE_(n-1)  (15)

[0051] where β is a user-defined programmable parameter, affecting the weight associated with the energies of the previous frames. Using equation (15), a target bit B_(1n) for the frame is defined as follows: $\begin{matrix} {B_{1n} = {{\left( \frac{e_{n}}{E_{n}} \right)^{\sigma_{0}}B_{avg}} - {\frac{1}{8}{{round}\left( {\sigma_{1}\left( {\psi_{n} - \frac{\sigma_{2}}{8}} \right)} \right)}B_{avg}}}} & (16) \end{matrix}$

[0052] In some embodiments, parameter σ₀ has a value of, e.g., zero or one. If σ₀ is selected to have a value of 0, the target bit rate is adjusted from the average bit rate B_(avg) in accordance with the buffer fullness. Therefore, if the buffer approaches fullness, the desired bit rate is decreased and vice versa. If σ₀ is selected to have a value of 1, the ratio of the energies e_(n) and E_(n) are used to compute the target bit rate. If the energy of current frame e_(n) is higher than the running average energy E_(n), a larger target bit rate is used. If the energy of current frame e_(n) is higher than the running average energy E_(n), a larger target bit rate is used. To inhibit buffer underflow and overflow, the target bit is required to be within a minimum B_(min) and a maximum value B_(max), as defined below: $\begin{matrix} {B_{1n} = \left\{ \begin{matrix} B_{\min} & {if} & {B_{1n} < B_{\min}} \\ B_{\max} & {if} & {B_{1n} < B_{\max}} \end{matrix} \right.} & (17) \end{matrix}$

[0053] Therefore, a common scale factor Q_(n) which results in an output bit rate that is close to the target bit rate B_(1n) is obtained. In one embodiment, a bisection algorithm is used to find a Q_(n) within lower and upper limits described in equations (12) and (13) and that would yield a rate close to the target rate, as described further below.

[0054]FIG. 2 shows the bit rates used for encoding as a function of the common scale factor Q_(n) used for this encoding. As seen from FIG. 2, the smaller the Q_(n), the larger is the bit rate that is used for encoding, and vice versa. To optimize Q_(n), a pair of bit rates that would result from encoding the frame using Q_(min) and Q_(max) are obtained. These bit rates are shown in FIG. 2 as points A and B. Next, the bit rate that would result from a Q_(n) which is half the sum of Q_(min) and Q_(max) is obtained, shown in FIG. 2 as Q₁. Next the target rate that would result from encoding the frame using Q₁ is obtained, shown in FIG. 2 as point C. Because target bit rate the bit rate B_(1n), is shown as being between B_(max) and C, the frame is next encoded using common scale factor Q₂ which is half the sum of Q_(min) and Q₁, which is shown in FIG. 2 as causing a bit rate D. As is understood by people skilled in the art, this process continues until an optimized common scale factor Q_(opt) that result in a bit rate that is close to target bit rate B_(1n) is obtained. Typically, after a few iterations, e.g. 5, the optimization is completed.

[0055] In some embodiments, to further reduce computations, Q_(max) may be used as the optimum solution, in which case the virtual buffer is filled with corresponding dummy bits, as known to those skilled in the art. In yet other embodiments, the Q_(1n) as defined in equation (8) is used as Q_(min). Following encoding of the frame, the number of bits in the virtual buffer that are used for encoding the next frame is updated as shown below:

U_(n+1=U) _(n)+B_(n)−B_(avg)  (18)

[0056]FIG. 3 shows a flow-chart 100 for predicting Qn as described above. In step 102, buffer fullness ψ_(n), defined in equation (2), is calculated. Next, in step 104, minimum and maximum bit rates B_(min), B_(max), defined in equations (3) and (4) are calculated. Next, in step 106, a running average θ_(n) of all previous common scale factors is calculated. Next, in step 108, as shown in equation (7), common scale factor Q_(n) is predicted. Next, in step 110, minimum and maximum common scale factors Q_(min), Q_(max) as well as the maximum value of the absolute values of MDCT coefficients raised to the three-fourth power M of a current is calculated, as shown in equations (12), (13) and (9). Next, in step 112, common scale factor Q_(n) is compared against Q_(min), Q_(max) and is set to Q_(min) if it is less than Q_(min) or is set to Q_(max) if it is greater than Q_(max), as described in equation (8). Next, in step 114, energy e_(n) of the current frame and a running average of the energies associated with all the previous frames E_(n) are computed. Next, in step 116, the frame is encoded using the common scale factor obtained in step 112 and the number of bits used to encode B_(n) is obtained. Next, in step 118, B_(n) is compared against the range defined by B_(min) and B_(max). If B_(n) is not within this range, in step 120, bit rate B_(n) is obtained, as defined in equations (16) and (17). Next, in step 122, bisection optimization is performed to find optimized Q_(n) and B_(n). Next, in step 124, the number of bits in the virtual buffer is updated. If B_(n) is within this range defined by B_(min) and B_(max), the algorithm moves to step 124 to update the number of bits in the virtual buffer. Next, in step 126, the next frame to be encoded is received and the process moves to step 102.

[0057] In accordance with a third aspect of the present invention, a rate control technique is adapted to optimize the common scale factor Q for each frame using scale factors q_(k) that have selected values and thus do not require optimization. Accordingly, because the common scale factor Q for each frame becomes the only unknown, as seen from equation (1) above, the rate control of the present inventions reduces the amount of computation required for obtaining the quantized MDCT coefficients. Moreover, the tradeoff between quantization distortion and output bit rate is achieved by varying the common scale factor Q.

[0058] In some embodiments, all scale factors q_(k) are selected to have the same constant value. In other embodiments, because humans are most sensitive to lower frequency signals, the scale factors associated with lower frequency bands are selected to have smaller values than those associated with lower frequency bands. In yet other embodiments, a look-up table may be used to select scale factors q_(k) values based on the frequency characteristic of the audio frame being encoded. Furthermore, in accordance with human acoustic responses, the scale factors may be selected such that larger step sizes are used for the scale factor bands that can tolerate larger quantization distortion.

[0059] In accordance with a fourth aspect of the present invention, the same common scalar factor Q is used for each channel of multi-channel system. Moreover, the scalar factors selected for one channel of a multi-channel system, as described above, together with one or more offset values are used to define the scalar factors of the remaining channels of such a system. In other words, after the scalar factors for one channel of a multi-channel system is selected, they are modified by corresponding offset values to determine the scalar factors for the remaining channels. In some embodiments, all the offsets for all channels may be select to be equal to a constant. In other embodiments, the offsets are selected in accordance with the complexity of the channel, such as the energy associated with the frames forwarded to that channel.

[0060] The above embodiments of the present invention are illustrative and not limitative. Other additions, subtractions or modification are obvious in view of the present invention and are intended to fall within the scope of the appended claims. 

What is claimed is:
 1. A method for encoding of a current audio frame, the method comprising: establishing minimum bit rate B_(min) and maximum bit rate B_(max) for the current frame, B_(min) and B_(max) being defined by a number of bits U_(n) stored in a buffer, maximum number of bits that the buffer is adapted to store U_(max) and an average bit rate B_(avg); establishing a running average of common scale factors θ_(n) of audio frames preceding the current audio frame; computing a common scale factor Q_(n) for the current frame using θ_(n); encoding the current frame using Q_(n) if Q_(n) falls within a range defined by a minimum common scale factor value Q_(min) and a maximum common scale factor value Q_(max); and verifying that encoding the current frame using Q_(n) requires a number of bits B_(n) that falls within a range defined by B_(min) and B_(max).
 2. The method of claim 1 further comprising: computing an energy level e_(n) associated with the current frame if B_(n) does not falls within B_(min) and B_(max); computing a running average of energies E_(n) of the audio frames preceding the current audio frame; computing a target bit rate B_(1n) associated with the current frame using e_(n) and E_(n); determining a common scale factor Q_(n) that results in a number of bits close to B_(1n) when the current frame is encoded therewith.
 3. The method of claim 2 wherein said B_(min) and B_(max) are defined in accordance with the following: $B_{\min} = \left\{ {{\begin{matrix} 0 & {if} & {U_{n} > B_{avg}} \\ {B_{avg} - U_{n}} & {if} & {U_{n} \leq B_{avg}} \end{matrix}B_{\max}} = {U_{\max} - U_{n} + {B_{avg}.}}} \right.$


4. The method of claim 3 wherein the common scale factor Q_(n) is computed using the running average of common scale factors θ_(n) of audio frames preceding the current audio frame in accordance with the following: ${Q_{n} = {\theta_{n} + {{round}\left( {\sigma_{1}\left( {\psi_{n} - \frac{\sigma_{2}}{8}} \right)} \right)}}};$

wherein θ_(n) is defined by: θ_(n)=(1−α)Q_(n-1)+αθ_(n-1) wherein σ₁ and σ₂ are programmable parameters, wherein ψ_(n) represent the buffer fullness defined by ${\psi_{n} = \frac{U_{n}}{U_{\max}}},$

wherein round( ) is an operator rounding the value of its operand, wherein θ_(n) is defined by θ_(n)=(1−α)Q_(n-1)+αθ_(n-1), wherein Q_(n-1) is a common scale factor for an audio frame preceding the current frame and wherein θ_(n-1) is a running average of common scale factors of audio frames preceding the frame preceding the current audio frame.
 5. The method of claim 4 wherein said Q_(min) and Q_(max) are defined as follows: $Q_{\min} = \left\lbrack {\frac{- 16}{3}\log_{2}\frac{2^{13} - m}{M}} \right\rbrack$ $Q_{\max} = \left\lbrack {\frac{- 16}{3}\log_{2}\frac{1 - m}{M}} \right\rbrack$

wherein m is a constant and wherein M is defined as: ${M = {\underset{i}{Max}\left( {C_{i}}^{3/4} \right)}},{i = 0},\quad \ldots \quad,1023$

wherein C_(i) is the i-th MDCT coefficient associated with the current audio frame.
 6. The method of claim 5 wherein the energy level en associated with the current frame is defined by: $e_{n} = {\frac{1}{N}{\sum\limits_{i = 0}^{N - 1}\quad {c_{i}}}}$

and wherein the running average of energies E_(n) of the audio frames preceding the current audio frame is defined by: $E_{n} = {\left( {1 - \beta} \right){\sum\limits_{i = {- \infty}}^{0}\quad {\beta^{- i}e_{i + n - 1}}}}$


7. The method of claim 6 wherein the target bit rate B_(1n) is defined by: $B_{1n} = {{\left( \frac{e_{n}}{E_{n}} \right)^{\sigma_{0}}B_{avg}} - {\frac{1}{8}{{round}\left( {\sigma_{1}\left( {\psi_{n} - \frac{\sigma_{2}}{8}} \right)} \right)}B_{avg}}}$

and wherein σ₀ is a programmable parameter.
 8. The method of claim 2 further comprising: updating the number of bits in the buffer after the current frame is encoded.
 9. The method of claim 7 wherein Q_(opt) is determined using a bisection algorithm.
 10. The method of claim 2 further comprising: assigning a value to each of a plurality of scale factors q_(k) associated with the current audio frame.
 11. The method of claim 2 wherein the current frame is received in a multi-channel system and wherein the common scale factor Q_(n) is used for encoding the current frame associated with each channel of the multi-channel system.
 12. The method of claim 11 further comprising: assigning a value to each of a plurality of scale factors q_(k) of the current associated with a first channel of the multi-channel system; and defining offsets between scale factors of the first channel and those of other channels of the multi-channel system.
 13. an apparatus adapted to set bit rate for encoding of a current audio frame, the apparatus comprising: a module adapted to establish minimum bit rate B_(min) and maximum bit rate B_(max) for the current frame, B_(min) and B_(max) being defined by a number of bits U_(n) stored in a buffer, maximum number of bits that the buffer is adapted to store U_(max) and an average bit rate B_(avg); a module adapted to establish a running average of common scale factors θ_(n), of audio frames preceding the current audio frame; a module adapted to compute a common scale factor Q_(n) for the current frame using θ_(n); a module adapted to encode the current frame using Q_(n) if Q_(n) falls within a range defined by a minimum common scale factor value Q_(n) and a maximum common scale factor value Q_(max); and a module adapted to verify that encoding the current frame using Q_(n) requires a number of bits B_(n) that falls within a range defined by B_(min) and B_(max).
 14. The apparatus of claim 13 further comprising: a module adapted to compute an energy level en associated with the current frame if B_(n) does not falls within B_(min) and B_(max); a module adapted to compute a running average of energies E_(n) of the audio frames preceding the current audio frame; a module adapted to compute a target bit rate B_(1n) associated with the current frame using e_(n) and E_(n); and a module adapted to determine a common scale factor Q_(opt) that results in a number of bits close to B_(1n) when the current frame is encoded therewith.
 15. The apparatus of claim 14 wherein said B_(min) and B_(max) are defined in accordance with the following: $B_{\min} = \left\{ {{\begin{matrix} 0 & {if} & {U_{n} > B_{avg}} \\ {B_{avg} - U_{n}} & {if} & {U_{n} \leq B_{avg}} \end{matrix}B_{\max}} = {U_{\max} - U_{n} + {B_{avg}.}}} \right.$


16. The apparatus of claim 15 wherein the common scale factor Q_(n) is computed using the running average of common scale factors θ_(n) of audio frames preceding the current audio frame in accordance with the following: ${Q_{n} = {\theta_{n} + {{round}\left( {\sigma_{1}\left( {\psi_{n} - \frac{\sigma_{2}}{8}} \right)} \right)}}};$

wherein θ_(n) is defined by: θ_(n)=(1−α)Q_(n-1)+αθ_(n-1) wherein σ₁ and σ₂ are programmable parameters, wherein ψ_(n) represent the buffer fullness defined by ${\psi_{n} = \frac{U_{n}}{U_{\max}}},$

wherein round( ) is an operator rounding the value of its operand, wherein θ_(n) is defined by θ_(n)=(1−α)Q_(n-1)+αθ_(n-1), wherein Q_(n-1) is a common scale factor for an audio frame preceding the current frame and wherein θ_(n-1) is a running average of common scale factors of audio frames preceding the frame preceding the current audio frame.
 17. The apparatus of claim 16 wherein said Q_(min) and Q_(max) are defined as follows: $Q_{\min} = \left\lbrack {\frac{- 16}{3}\quad \log_{2}\frac{2^{13} - m}{M}} \right\rbrack$ $Q_{\max} = \left\lbrack {\frac{- 16}{3}\quad \log_{2}\frac{1 - m}{M}} \right\rbrack$

wherein m is a constant and wherein M is defined as: ${M = {\underset{i}{Max}\left( {C_{i}}^{3/4} \right)}},{i = 0},\ldots \quad,1023$

wherein C_(i) is the i-th MDCT coefficient associated with the current audio frame.
 18. The apparatus of claim 17 wherein the energy level e_(n) associated with the current frame is defined by: $e_{n} = {\frac{1}{N}{\sum\limits_{i = 0}^{N - 1}{c_{i}}}}$

and wherein the running average of energies E_(n) of the audio frames preceding the current audio frame is defined by: $E_{n} = {\left( {1 - \beta} \right)\quad {\sum\limits_{i = {- \infty}}^{0}{\beta^{- i}e_{i + n - 1}}}}$


19. The apparatus of claim 18 wherein the target bit rate B_(1n) is defined by: $B_{1n} = {{\left( \frac{e_{n}}{E_{n}} \right)^{\sigma_{0}}\quad B_{avg}} - {\frac{1}{8}{{round}\left( {\sigma_{1}\left( {\psi_{n} - \frac{\sigma_{2}}{8}} \right)} \right)}B_{avg}}}$

and wherein σ₀ is a programmable parameter. 